<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

		<title>来料检</title>
		<!-- 页面样式 -->
		<link rel="stylesheet" href="../../../static/assets/css/QMS/PageCss/DocumentsPage.css">
		<!-- <link rel="stylesheet" href="http://at.alicdn.com/t/c/font_4096975_i8f4jjygw.css"> -->
		<link rel="stylesheet" href="../../../static/assets/css/QMS/vant.min.css">
		<link rel="stylesheet" href="../../../static/assets/css/QMS/element.css">

		<script src="../../../static/assets/script/my-xmlhttprequest.js"></script>
		<script src="../../../static/assets/script/jquery.js"></script>
		<script src="../../../static/assets/script/vue.min.js"></script>
		<script src="../../../static/assets/script/vant.min.js"></script>
		<script src="../../../static/assets/script/element.js"></script>
		<script src="../../../static/assets/script/plugin.js"></script>
		<script src="../../../static/assets/script/umd.js"></script>
		<script src="../../../static/assets/js/base.js"></script>
		<script type="text/javascript" src="https://www.layuicdn.com/layer-v3.5.1/layer.js"></script>
		<script src="../../../static/assets/script/vue.min.js"></script>
		<style>
			html,
			body,
			#app {
				height: 100%;
			}
		</style>
	</head>
	<body>
		<div id="app" v-cloak>
			<div id="container"></div>
		</div>
	</body>
	<!-- 调用 uniapp webview 的 api ，记得需要写在 body 标签下面 -->
	<!-- <script src="../../../static/assets/script/uni.webview.1.5.4.js"></script> -->

	<script>
		// 开启 h5 页面 与 vue主页面的 信息交互
		// document.addEventListener('UniAppJSBridgeReady', function() {
		// 	// uni.postMessage({
		// 	// 	data: {
		// 	// 		action: 'message'
		// 	// 	}
		// 	// });
		// })

		var vm = new Vue({
			el: '#app',
			data: {
				loading: true,
			},
			created: function() {
				var that = this;

				this.$nextTick(function() {

					// console.log(parent.vm.WorkInstructions)

					// console.log(APP.serverIP())

					layer.open({
						type: 2,
						title: '文件预览',
						area: ['100%', '100%'],
						// content: 'preview.html',
						// content: 'preview.html?src='+url,
						// 'https://df58244856.zicp.fun/assets/preOffice/preview.html?src='
						content: APP.IPAgreement() + APP.serverIP() +
							'/assets/preOffice/preview.html?src=' +
							APP.IPAgreement() + APP.serverIP() + parent.vm.FilePath,
						// maxmin: true,
						offset: 't',
						// shadeClose: true,
						cancel: function() {
							// 处理关闭操作事件
							layer.closeAll();
							parent.vm.IsShowWorkPage = false;
							parent.vm.getPageData();
						}
					});
				})

			},
			computed: {},
			watch: {},
			mounted() {
				var that = this;
			},
			beforeDestroy() {},
			methods: {}
		})

		// 监听屏幕旋转
		window.addEventListener("orientationchange", function() {

			if (Math.abs(window.orientation) === 90) {
				// console.log('这是竖屏')
			}
			if (Math.abs(window.orientation) === 0) {
				// console.log('这是横屏')
			}
		}, false);


		/** 根据选中的单元格位置，获取单元格的信息 用于'originData.inspections'
		 * @param arr  搜寻的原数组， this.originData.inspections
		 * @param data 选中的坐标位置，如 {r:0,c:0}
		 */
		function GetChoiceCellData(arr, data) {
			var that = this
			for (var i = 0; i < arr.length; i++) {
				for (var j = 0; j < arr[i].FQCItems.length; j++) {

					if (arr[i].FQCItems[j].r == data.r &&
						arr[i].FQCItems[j].c == data.c) {

						return arr[i].FQCItems[j]
					}
				}
			}
		}

		/**
		 * 求百分比函数
		 * 求该字段在数组中所占百分比
		 * @param arr 		对象数组
		 * @param attribute 字段名称
		 * @param value 	比较的值
		 * @return {string} 返回一个字符串（'50%'）
		 */
		function BackRercentageData(arr, attribute, value) {

			let MeetNums = arr.filter(item => {
				return item[attribute] == value
			}).length

			let num = parseFloat(MeetNums);
			let total = parseFloat(arr.length);

			if (isNaN(num) || isNaN(total)) {
				return "-";
			}
			return total <= 0 ? "0%" : Math.round((num / total) * 10000) / 100.0 + "%";
		}

		/**
		 * 求百分比
		 * @param  num 		当前数
		 * @param  total 	总数
		 * @return {string} 返回一个字符串（'50%'）
		 */
		function getPercent(num, total) {
			num = parseFloat(num);
			total = parseFloat(total);
			if (isNaN(num) || isNaN(total)) {
				return "-";
			}
			return total <= 0 ? "0%" : Math.round((num / total) * 10000) / 100.0 + "%";
		}

		/** 求对象数组中某一属性最大值
		 * @param arr 对象数组
		 * @param key 对比的属性
		 */
		function countMax(arr, key) {
			return Math.max.apply(Math, arr.map(item => {
				return item[key]
			}))
		}
	</script>

</html>